package com.example.palette.util;

import android.view.View;

public abstract class QuickClickListener implements View.OnClickListener {

    private long mEffectDelayTime = 1000;
    private long mLastEffectTime = 0;

    public QuickClickListener() {
    }

    public QuickClickListener(long delayTime) {
        this.mEffectDelayTime = delayTime;
    }

    @Override
    public void onClick(View v) {
        long current = System.currentTimeMillis();
        if (current - mLastEffectTime > mEffectDelayTime) {
            mLastEffectTime = current;
            onQuickClickEffect(v);
        } else {
            onQuickClickNoEffect(v);
        }
    }

    public abstract void onQuickClickEffect(View v);

    public void onQuickClickNoEffect(View v) {

    }
}
